package com.zego.wawaji.ui.store.car.adapter;

import android.view.View;

import com.zego.wawaji.R;
import com.zego.wawaji.base.log.PToast;
import com.zego.wawaji.ui.base.recycler.BaseRecyclerViewAdapter;
import com.zego.wawaji.ui.base.recycler.BaseRecyclerViewHolder;
import com.zego.wawaji.ui.base.recycler.swipe.SwipeItemLayout;
import com.zego.wawaji.ui.view.counter.SnappingStepper;
import com.zego.wawaji.ui.view.counter.listener.SnappingStepperValueChangeListener;

/**
 * Created by Su on 2018/1/8.
 */
public class StoreCarAdapter extends BaseRecyclerViewAdapter<String> implements View.OnClickListener {
    @Override
    public int[] getItemLayouts() {
        return new int[]{R.layout.store_car_item};
    }

    @Override
    public void onBindRecycleViewHolder(BaseRecyclerViewHolder viewHolder, final int position) {
        View marginTop = viewHolder.findViewById(R.id.margin_top);
        marginTop.setVisibility(View.GONE);
        if (position == 0) {
            marginTop.setVisibility(View.VISIBLE);
        }

        String data = getItem(position);

        SnappingStepper stepper = viewHolder.findViewById(R.id.stepper);
        stepper.setOnValueChangeListener(new SnappingStepperValueChangeListener() {
            @Override
            public void onValueChange(View view, int value) {
                PToast.showShort(position + ":  " + value);
            }
        });

        // 侧滑
        final SwipeItemLayout swipeItemLayout = viewHolder.findViewById(R.id.swipe_layout);
        View mRightMenu = viewHolder.findViewById(R.id.right_menu);
        swipeItemLayout.setSwipeEnable(true);
        mRightMenu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                swipeItemLayout.close();
            }
        });
    }

    @Override
    public int getRecycleViewItemType(int position) {
        return 0;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.delete:       // 删除
                break;
        }
    }
}
